Skip to content

app: thread HeapAllocator through core module Init calls - #284

Merged
al1img merged 3 commits into
aosedge:developfrom
al1img:redesign_allocator
Aug 4, 2026
Merged

app: thread HeapAllocator through core module Init calls#284
al1img merged 3 commits into
aosedge:developfrom
al1img:redesign_allocator

Conversation

@al1img

@al1img al1img commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Aos core library APIs (crypto provider, PKCS11 manager, cert loader, cert handler, space allocators, image manager, launcher, monitoring, network manager, node config handler, etc.) now take an allocator as part of their redesigned Init signatures, so every app entry point (cm, iam, mp, sm) gains a HeapAllocator member and passes it through.

Also refactors the IAM app to move its Init/Start/Stop logic out of App into a new AosCore class, matching the pattern already used by cm and sm, which keeps App as a thin Poco::Util::ServerApplication wrapper around AosCore.

Updates the affected unit tests to construct a HeapAllocator and pass it to the library calls whose signatures changed, and fixes FSPlatform::GetDirSize to call the renamed common::utils::CalculateSize helper instead of the removed aos::fs::CalculateSize.

@al1img
al1img force-pushed the redesign_allocator branch 3 times, most recently from cb02d98 to a56cb25 Compare July 31, 2026 15:17
RetWithError<size_t> FSPlatform::GetDirSize(const String& dir) const
{
return fs::CalculateSize(dir);
return common::utils::CalculateSize(dir.CStr());

@MykolaSuperman MykolaSuperman Aug 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve directory sizes above INT_MAX

This switches production space accounting to common::utils::CalculateSize, whose std::accumulate starts with the literal 0, making the accumulator an int. Directories larger than INT_MAX therefore overflow before the result is converted to uintmax_t. Image and install directories can commonly exceed 2 GiB, so SpaceAllocator may receive a bogus size and make incorrect allocation or cleanup decisions. Please initialize the accumulator with uintmax_t {0} and also maybe good to add test on this case.

Comment thread src/iam/app/aoscore.cpp Outdated
@@ -0,0 +1,294 @@
/*
* Copyright (C) 2024 Renesas Electronics Corporation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026

@mykola-kobets-epam mykola-kobets-epam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>

Comment thread src/iam/app/aoscore.hpp Outdated
@@ -0,0 +1,108 @@
/*
* Copyright (C) 2024 Renesas Electronics Corporation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026

@mlohvynenko mlohvynenko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>

@al1img
al1img force-pushed the redesign_allocator branch 2 times, most recently from a178218 to d4ab7a0 Compare August 4, 2026 12:13
al1img added 3 commits August 4, 2026 15:13
Aos core library APIs (crypto provider, PKCS11 manager, cert loader,
cert handler, space allocators, image manager, launcher, monitoring,
network manager, node config handler, etc.) now take an allocator as
part of their redesigned Init signatures, so every app entry point
(cm, iam, mp, sm) gains a HeapAllocator member and passes it through.

Also refactors the IAM app to move its Init/Start/Stop logic out of
App into a new AosCore class, matching the pattern already used by
cm and sm, which keeps App as a thin Poco::Util::ServerApplication
wrapper around AosCore.

Updates the affected unit tests to construct a HeapAllocator and
pass it to the library calls whose signatures changed, and fixes
FSPlatform::GetDirSize to call the renamed common::utils::CalculateSize
helper instead of the removed aos::fs::CalculateSize.

Signed-off-by: Oleksandr Grytsov <al1img@gmail.com>
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
std::accumulate was seeded with an int literal 0, so the running
total was accumulated as int and only converted to uintmax_t on
return. Directories whose aggregate size exceeds INT_MAX (~2 GiB)
overflowed before conversion, which can make SpaceAllocator receive
a bogus size and make incorrect allocation or cleanup decisions.

Seed the accumulator with uintmax_t{0} instead, and add a regression
test that sums two sub-INT_MAX sparse files whose total crosses
INT_MAX.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
The templateRecursion suppressions are no longer needed for these
two make_unique<Alerts> calls.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
@al1img
al1img force-pushed the redesign_allocator branch from d4ab7a0 to cb44988 Compare August 4, 2026 12:14
@al1img
al1img merged commit 6dc27c3 into aosedge:develop Aug 4, 2026
4 of 5 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants